import { FlyFootBmp } from "./FlyFootBmp";
import { TaskTargetInfo } from "../../../model/TaskTargetInfo";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
type int = number;
//class FlyFoot
    
    export  class FlyFoot /* flash.display.Sprite */
    {
        constructor()
        {
            
            mouseEnabled = false;
            this._flyFootBmp = new FlyFootBmp();
            addChild(this._flyFootBmp);
            this._flyFootBmp.addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            this._flyFootBmp.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._flyFootBmp.addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            return;
        }

        public updateData(arg1: int, arg2: int, arg3: int, arg4: int=0, arg5: int=10004, arg6: int=0, arg7: int=0): void
        {
            this.dispose();
            this._px = arg1;
            this._py = arg2;
            this._mapId = arg3;
            this._proxyId = arg6;
            this._serverId = arg7;
            this._targetId = arg4;
            this._targetType = arg5;
            this._timerKey = flash.utils.setTimeout(this.onTimerOutHandler, 3000);
            return;
        }

        /* internal  */onTimerOutHandler(): void
        {
            this.dispose();
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this._target) 
            {
                this._target = new TaskTargetInfo();
            }
            this._target.x = this._px;
            this._target.y = this._py;
            this._target.mapId = this._mapId;
            this._target.proxyId = this._proxyId;
            this._target.serverId = this._serverId;
            this._target.id = this._targetId;
            this._target.targetType = this._targetType;
            AIManager.onAIControl(this._target, AIType.AI_Convey);
            return;
        }

        /* internal  */onMouseOverHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            flash.utils.clearTimeout(this._timerKey);
            return;
        }

        /* internal  */onMouseOutHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this._timerKey = flash.utils.setTimeout(this.onTimerOutHandler, 3000);
            return;
        }

        public dispose(): void
        {
            flash.utils.clearTimeout(this._timerKey);
            if (parent != null) 
            {
                parent.removeChild(this);
            }
            return;
        }

        /* internal */ /* var */_flyFootBmp: FlyFootBmp;

        /* internal */ /* var */_target: TaskTargetInfo;

        /* internal */ /* var */_px: int;

        /* internal */ /* var */_py: int;

        /* internal */ /* var */_mapId: int;

        /* internal */ /* var */_proxyId: int;

        /* internal */ /* var */_serverId: int;

        /* internal */ /* var */_timerKey: uint;

        /* internal */ /* var */_targetType: int;

        /* internal */ /* var */_targetId: int;
    }
